const BASE_URL = "http://123.207.32.32:9001/"

class YZRequest {
  constructor(baseUrl = BASE_URL) {
    this.baseUrl = baseUrl
  }
  request(url, method, params) {
    return new Promise((resolve, reject) => {
      wx.request({
        url: this.baseUrl + url,
        method: method,
        data: params,
        success: function(res) {
          resolve(res.data)
        },
        fail: function(err) {
          reject(err)
        }
      })
    })
  }
  
  get(url, params) {
    return this.request(url, "GET", params)
  }

  post(url, params) {
    return this.request(url, "POST", params)
  }

}

// 实例
const yzRequest = new YZRequest()

export default yzRequest


